﻿using PicturePortfolio.Persistance;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using PicturePortfolio.Domain;
namespace PersistanceTest
{
    
    
    /// <summary>
    ///This is a test class for GenericRepositoryTest and is intended
    ///to contain all GenericRepositoryTest Unit Tests
    ///</summary>
    [TestClass()]
    public class GenericRepositoryTest
    {

        public GenericRepositoryTest() { }
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for GetAll
        ///</summary>
        public void GetAllTestHelper<TEntity>()
            where TEntity : class
        {
            IRepository target = new GenericRepository(); // TODO: Initialize to an appropriate value
            IList<Photo> expected = null; // TODO: Initialize to an appropriate value
            IList<Photo> actual;
            actual = target.GetAll<Photo>();
            Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }

        [TestMethod()]
        public void GetAllTest()
        {
            GenericRepository target = new GenericRepository(); // TODO: Initialize to an appropriate value
            IList<Photo> expected = null; // TODO: Initialize to an appropriate value
            IList<Photo> actual;
            actual = target.GetAll<Photo>();
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void AddTest()
        {
            PublicComment comment = new PublicComment();
            comment.Comment = "Some thing";
            comment.CommentDate = DateTime.Now;
            comment.UserName = "Sony";
            GenericRepository target = new GenericRepository();
            target.Add<PublicComment>(comment);

            IList<PublicComment> expected = target.GetAll<PublicComment>();
        }

        [TestMethod]
        public void AddPhotoTest()
        {
            Photo photo = new Photo();
            photo.Name = "mountain.jpg";
            photo.Description = "kjnkdjfnde";
            photo.PublicComments = new List<PublicComment>();
            GenericRepository target = new GenericRepository();
            target.Add<PhotoPersistanceObject>(photo.GetDataForPersistance());

            IList<PhotoPersistanceObject> expected = target.GetAll<PhotoPersistanceObject>();
        }

        [TestMethod]
        public void AddCategory()
        {
            List<Category> categories = new List<Category>();
            categories.Add(new Category { CategoryName = "Nature",CategoryThumbNail=new byte[0] });
            categories.Add(new Category { CategoryName = "Portrait",CategoryThumbNail=new byte[0] });
            categories.Add(new Category { CategoryName="Wild Life",CategoryThumbNail=new byte[0] });
            GenericRepository target = new GenericRepository();
            foreach (Category category in categories)
            {
                target.Add<Category>(category);
            }
        }
    }
}
